﻿using System;
using System.Collections.Generic;

namespace SEP.Admin
{
    public partial class DataTablesTestbed : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //just a dumb query to try out
            //JQueryDataTable1.ConnectionString = "SEP";
            //JQueryDataTable1.SqlToExecute = "select   FirstName  ,MiddleName  ,LastName  ,LastNamePrefix  ,Name  ,IsOrganization  ,IsPrimary  ,IsActive  ,PrimaryID  ,ID  ,DateChanged  ,DateAdded  ,AddedByID  ,ChangedByID from   constituent";
            JQueryDataTable1.TableData = GetAllConstituents();
        }

        protected List<BusinessLogic.Table> GetAllConstituents()
        {
            List<BusinessLogic.Table> result = new List<BusinessLogic.Table>();

            DatabaseWrapper dbw = new DatabaseWrapper("SEP", "SELECT ID FROM CONSTITUENT", System.Data.CommandType.Text);
            System.Data.DataTable dt = dbw.ExecuteDataTable();

            foreach (System.Data.DataRow rw in dt.Rows)
            {
                result.Add(new BusinessLogic.Constituent(new Guid(rw["ID"].ToString())));
            }
            return result;
        }
    }
}